import JSEncrypt from 'jsencrypt';

// 密码加盐&公钥加密
export function saltAndEncryptPassword(password) {
  // 1.密码加盐
  const salt = 'mall_salt'
  const saltedPassword = password + salt;
  const encrypt = new JSEncrypt();
  // 2.公钥
  const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtZ9HyuZwgLD2DhaX6OAiw7kTN2VK4jKxRA/AxYoEG495nLFXwliiFBG5PHGDnlDCmLoJyFzgc2eaLajbHHr7i3/qCo6n4Rm9VkgyYtAVTMO6t6B/PBxRVg/QzgXYpYXu2U4Gof33hd4CaP8xKH2aZc76QHo1BVpMfzY5ZMdPN6BpHD8YQy9n21r7TPP5Rr2ab9/d0eLGvCwMU3LfvZG8v+EOXenbiiZCYTnhR+Cg/J118GgBnXEVqgdU1kwDSx7kxAu9CeaBLySXttZOZL6GJivQjy9KnQnR9IypslYCNq2Dcfivd76Hyal4xno44eGK6rdwfqx7WZ5dnRoK+SQfsQIDAQAB';
  encrypt.setPublicKey(publicKey);
  // 3.公钥加密
  return encrypt.encrypt(saltedPassword);
}
